import 'package:home/entity/device_entity.dart';

deviceEntityFromJson(StationDevice data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['ip'] != null) {
		data.ip = json['ip'].toString();
	}
	if (json['deviceType'] != null) {
		data.deviceType = json['deviceType'].toString();
	}
	if (json['macAddress'] != null) {
		data.macAddress = json['macAddress'].toString();
	}
	return data;
}

Map<String, dynamic> deviceEntityToJson(StationDevice entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['ip'] = entity.ip;
	data['deviceType'] = entity.deviceType;
	data['macAddress'] = entity.macAddress;
	return data;
}